package com.atguigu.strategy.improve;

public abstract class Duck {
	
	//属性，策略接口
	FlyBehavior flyBehavior;
	//其他属性<->策略接口
	QuackBehavior quackBehavior;
	
	public Duck() {
	}
	
	public void quack() {
		//改进
		if (quackBehavior != null) {
			quackBehavior.quack();
		}
	}
	
	public void swim() {
		System.out.println("鸭子游泳");
	}
	
	public void fly() {
		//改进
		if (flyBehavior != null) {
			flyBehavior.fly();
		}
	}
	
	public abstract void display();

	public void setFlyBehavior(FlyBehavior flyBehavior) {
		this.flyBehavior = flyBehavior;
	}

	public void setQuackBehavior(QuackBehavior quackBehavior) {
		this.quackBehavior = quackBehavior;
	}
}
